using System;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using Microsoft.SharePoint.Utilities;

namespace SharePointListSecurity.Features.SharePointListSecurityAlertMe
{
    /// <summary>
    /// This class handles events raised during feature activation, deactivation, installation, uninstallation, and upgrade.
    /// </summary>
    /// <remarks>
    /// The GUID attached to this class may be used during packaging and should not be modified.
    /// </remarks>

    [Guid("93f227a2-b092-4a9a-8def-ab28e11a321e")]
    public class SharePointListSecurityAlertMeEventReceiver : SPFeatureReceiver
    {
        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPWebApplication webApplication = (SPWebApplication)properties.Feature.Parent;
            SPAlertTemplateCollection alertTemplateCollection = new SPAlertTemplateCollection((SPWebService)(webApplication.Parent));
            alertTemplateCollection.InitAlertTemplatesFromFile(SPUtility.GetGenericSetupPath(@"TEMPLATE\XML") + @"\customalerttemplates.xml");

        }

        public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {
            SPWebApplication webApplication = (SPWebApplication)properties.Feature.Parent;
            SPAlertTemplateCollection alertTemplateCollection = new SPAlertTemplateCollection((SPWebService)(webApplication.Parent));
            alertTemplateCollection.InitAlertTemplatesFromFile(SPUtility.GetGenericSetupPath(@"TEMPLATE\XML") + @"\AlertTemplates.xml");
        }
    }
}
